import { zbCode, ybCode, zlCode, stateCode } from '@/config/code';
/**
 * 计算付账细节的函数
 * @param code {string} 付账编码
 * @param total {number} 已付账的金额
 * @example countMoney('01FF', 10)
 */

export const countMoney = (code, total = 0) => {
	// const _code = code.toUpperCase();// 转成大写
	// const _code = code.toLowerCase(); // 转成小写
	const _code = code;
	let _money = 0;
	let _total = total;
	switch (_code) {
		case zbCode.money_100:
			_money = 100;
			break;
		case zbCode.money_500:
			_money = 500;
			break;
		case zbCode.money_1000:
			_money = 1000;
			break;
		case ybCode.money_50:
			_money = 50;
			break;
		default:
			_money = 0;
	}
	_total += _money;
	console.log('_total: ', _total);
	return _total;
};

/**
 * 计算找零的函数
 * @param code {string} 付账编码
 * @param total {number} 已付账的金额
 * @example countYBMoney('050103070010', 10)
 */

export const countYBMoney = (code, total = 0) => {
	const _code = code && code.length > 12 ? code.slice(0, 12) : code;
	let _money = 0;
	let _total = total;
	switch (_code) {
		case zlCode.payout_return:
			_money = 50;
			break;
		default:
			_money = 0;
	}
	_total += _money;
	console.log('_total: ', _total);
	return _total;
};

/**
 * 计算找零的函数
 * @param code {string} 付账编码
 * @param total {number} 已付账的金额
 * @example countZLMoney('050103070010', 10)
 */

export const countZLMoney = (code, total = 0) => {
	const _code = code && code.length > 12 ? code.slice(0, 12) : code;
	let _money = 0;
	let _total = total;
	switch (_code) {
		case zlCode.payout_return:
			_money = 50;
			break;
		default:
			_money = 0;
	}
	_total += _money;
	console.log('_total: ', _total);
	return _total;
};

/**
 * 根据找零硬币数量返回相应指令的函数
 * @param count {number} 硬币数量
 * @returns {string} 返回硬币相应数量对应的指令
 * @example countZLSend(10)
 */

export const countZLSend = count => {
	const _count = count;
	let _code = '';
	switch (_count) {
		case 1:
			_code = zlCode.money_payoutCoin1;
			break;
		case 2:
			_code = zlCode.money_payoutCoin2;
			break;
		case 3:
			_code = zlCode.money_payoutCoin3;
			break;
		case 4:
			_code = zlCode.money_payoutCoin4;
			break;
		case 5:
			_code = zlCode.money_payoutCoin5;
			break;
		case 6:
			_code = zlCode.money_payoutCoin6;
			break;
		case 7:
			_code = zlCode.money_payoutCoin7;
			break;
		case 8:
			_code = zlCode.money_payoutCoin8;
			break;
		case 9:
			_code = zlCode.money_payoutCoin9;
			break;
		case 10:
			_code = zlCode.money_payoutCoin10;
			break;
		case 11:
			_code = zlCode.money_payoutCoin11;
			break;
		case 12:
			_code = zlCode.money_payoutCoin12;
			break;
		case 13:
			_code = zlCode.money_payoutCoin13;
			break;
		case 14:
			_code = zlCode.money_payoutCoin14;
			break;
		case 15:
			_code = zlCode.money_payoutCoin15;
			break;
		case 16:
			_code = zlCode.money_payoutCoin16;
			break;
		case 17:
			_code = zlCode.money_payoutCoin17;
			break;
		case 18:
			_code = zlCode.money_payoutCoin18;
			break;
		case 19:
			_code = zlCode.money_payoutCoin19;
			break;
		case 20:
			_code = zlCode.money_payoutCoin20;
			break;
		default:
			_code = '';
	}
	console.log('_code: ', _code);
	return _code;
};
